﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>FilesUpload</title>
    <style type="text/css">
        #queue {
            background-color: #FFF;
            border: 1px solid #E5E5E5;
            border-radius: 5px;
            height: 178px;
            margin-bottom: 5px;
            overflow: auto;
            padding: 3px;
            width: 300px;
        }
    </style>
    <script src="~/Content/js/jquery-1.8.2.js"></script>
</head>
<body>
    <div>
        <form id="form" enctype="multipart/form-data">
            <table>
                <tr>
                    <td>Name:</td>
                    <td colspan="3">
                        <input name="objFileEntity.Name" type="text" /></td>
                </tr>
                <tr>
                    @*<td>Image:</td>
                    <td>
                        <input id="file_upload" data-options='{"Id":"0","CategoryCode":"Systems","LimitCode":"MaxImg",Name:"test","ServerPath":""}' type="file" />
                        <input name="test" type="hidden" />
                    </td>                    
                    <td>
                        <img class="file_upload" src="#" />
                    </td>*@
                </tr>
            </table>
            @*<div id="queue"></div>
            <input type="file" name="file_upload" id="file_upload_1" />
            <a href="javascript:$('#file_upload_1').uploadify('upload')">Upload Files</a>*@
            <input type="file" name="file_upload" id="file_upload_2" />
        </form>
    </div>
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/js/tjzheng.js"></script>
    <script src="~/Content/uploadify/jquery.uploadify.js"></script>
    <link href="~/Content/uploadify/uploadify.css" rel="stylesheet" />
    <script type="text/javascript">
        //$('#file_upload').uploadify({
        //    swf: '/Content/uploadify/uploadify.swf',
        //    uploader: '/Files/Uploads',
        //    buttonText: "请选择",
        //    multi: false,
        //    formData: { "objUploadSet": $('#file_upload').attr("data-params") },
        //    fileObjName: "objFile",
        //    buttonClass: 'someClass',
        //    fileTypeExts: '*.gif; *.jpg; *.png',
        //    fileSizeLimit: 100,
        //    onUploadSuccess: function (objFile, objInvokeResult) {
        //        objInvokeResult = JSON.parse(objInvokeResult);
        //        if (objInvokeResult.ResultCode == "Success") {
        //            $("#maxImg").attr("src", objInvokeResult.Data);
        //        } else {
        //            alert(objInvokeResult.ResultMessage);
        //        }
        //    }
        //    //itemTemplate: '<div class="uploadifive-queue-item"><span class="filename"></span> | <span class="fileinfo"></span><div class="close"></div></div>'
        //    //itemTemplate: '',
        //});

        //var objFileUpload = new FileUpload("#file_upload");
        //objFileUpload.multi = true;
        //objFileUpload.url = "/files/uploads";
        //objFileUpload.formData = { "UploadSet": $('#file_upload').attr("data-options") };
        //objFileUpload.fileObjName = "objFile";
        //objFileUpload.fileTypeExts = '*.gif; *.jpg; *.png';
        //objFileUpload.fileSizeLimit = 1024;
        //objFileUpload.uploadSuccess = SingleImgSuccess;
        //objFileUpload.itemTemplate = '<span></span>';
        //objFileUpload.uploadify();

        //function SingleImgSuccess(objFile, objInvokeResult) {
        //    if (objInvokeResult.ResultCode == "Success") {
        //        var imgSelector = "img." + this.selector.replace("#", "");
        //        $(imgSelector).attr("src", objInvokeResult.Data);
        //        $("input[name=" + StringToJosn(this.formData.UploadSet).Name + "]").val(objInvokeResult.Data);
        //    } else {
        //        alert(objInvokeResult.ResultMessage);
        //    }
        //}

        //$('#file_upload_1').uploadify({
        //    'swf': '/Content/uploadify/uploadify.swf',
        //    'auto': false,
        //    'dnd': true,
        //    'queueID': 'queue',
        //    'uploader': '/Files/Uploads',
        //    'fileObjName': "objFile",
        //});

        //Init_UploadControl();

        $(function () {
            setTimeout(function () {
                Init_UploadControl();
            }, 10)
        });

        function Init_UploadControl() {
            $('#file_upload_2').uploadify({
                swf: '/Content/uploadify/uploadify.swf',
                uploader: '/Files/Uploads',
                buttonText: "请选择",
                fileObjName: "objFile",
                buttonClass: 'someClass',
                auto: false
            });
        }
    </script>
</body>
</html>
